<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>我是主页</h1>
    <table border="1">
        <tr id="tr1">
            <th>商品列表</th>
        </tr>
    </table>
</body>
<script>
    $(function(){
        //onload ajax 查商品列表信息
        //取出token
        var mstoken=localStorage.getItem("mstoken");
        $.ajax({
            headers:{token: mstoken},
            url:"http://localhost:8080/goods",
            method:"post",
            data:{
                "stname":"zhouchen",
                "stpass":"66666"
            },
            success:function(data){
                alert(data.message)
                if(data.success==true){
                for(var i=0;i<data.data.length;i++){
                    $("#tr1").after("<tr><td>"+data.data[i].name+"</td></tr>")
                }
                }else{
                    alert("登陆已失效,请重新登陆")
                    $(".app").load("login.html")
                }
                
            }
        })
    })

    console.log("good morning!");
</script>
</html>